#ifndef CLOCK_H
#define CLOCK_H
#include <SDL.h>
#include <string>
#include <iostream>
#include <fstream>

class Clock {
public:
  Clock();
  unsigned getTotalTicks() const;
  Clock& operator++();
  Clock  operator++(int);
  bool isStarted() const { return started; }
  bool isPaused() const  { return paused;  }
  unsigned getFrames() const  { return frames;  }
  unsigned getSeconds() const { return getTotalTicks()/1000;  }
  float getFps() const;
  unsigned getElapsedTicks();

  void start();
  void pause();
  void unpause();
  void debug() const;
  //void save(std::fstream& xmlfile) const;
  //void restore(const std::string& filename);

private:
  bool started;
  bool paused;
  unsigned long frames;
  unsigned long timeAtStart;
  unsigned long timeAtPause;
  unsigned long currTicks;
  unsigned long prevTicks;
  unsigned long ticks;

  Clock(const Clock&);
  Clock&operator=(const Clock&);
};
#endif
